package org.uim.cricket.storage.backup;

import org.uim.cricket.util.io.FileSaver;

public abstract class BackupFetchedData implements Backupable {

	private String destinationFile = null;
	private StringBuilder data = null;
	
	public BackupFetchedData(StringBuilder theData) {
		this.data = theData;
	}
	
	protected boolean backupFunc(String file) throws Exception {
		if (file == null || file.length() == 0) throw new IllegalArgumentException ("Filename for for backup can't be null!");
		
		String fName = file;
		FileSaver fs = new FileSaver(fName);
		fs.write(data);
		
		return true;
	}
	
	public void setDestinationFile(String destinationFile) {
		this.destinationFile = destinationFile;
	}
	
	public String getDestinationFile() {
		return destinationFile;
	}

	public void setData(StringBuilder data) {
		this.data = data;
	}
	
	public StringBuilder getData() {
		return data;
	}
}
